home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / ste / 50play.lzh / FRQ32BIT.C < prev    next >
C/C++ Source or Header  |  1985-11-20  |  694b  |  29 lines

  1. /* Amiga Period -> ST 16bit integer / 32bit Fraction convert.     */
  2. /* Dodgy 'C' code By Griff.. (Compile with GCC 2.0 or above...) */
  3.  
  4. #include <stdio.h>
  5. #define FILENAME "FRQ32BIT.TAB"
  6. double frac(double x);
  7.  
  8. void main()
  9. {    FILE *out;
  10.     double per,work,freq_amiga=3579545.0,freq_st=25033.0;
  11.     unsigned long i;
  12.     void *x;
  13.     out = fopen(FILENAME,"wb");
  14.     x = (&i);
  15.     for (per = 1 ; per <= (1024+256) ; per++) 
  16.     {    work = (freq_amiga/per)/freq_st; /* whole part    */
  17.         i = work;
  18.         i = i << 16;
  19.         fwrite(x,2,1,out);        /* output int    */
  20.         i = (frac(work)*4294967296.0);
  21.         fwrite(x,4,1,out);        /* output frac    */
  22.     }
  23.     fclose(out);
  24. }
  25.  
  26. double frac(double x)
  27. {    int i;
  28.     return (x - (i=x));
  29. }